package db.dbo;

import java.util.List;

import org.apache.log4j.Logger;

import db.dao.DictionariesDAO;
import db.dto.DictionariesDTO;
import dict.Dictionary;

public class DictionariesDBO {
	Logger LOG = Logger.getLogger("DictionariesDBO");
	public String lookupWord(int dictID, String word) {
		DictionariesDAO dictDAO = new DictionariesDAO();
		DictionariesDTO dict = dictDAO.getDictionary(dictID);
		Dictionary dictionary = new Dictionary(dict.getUrl(), dict.getDelCount());
		String meaning =  dictionary.lookupWord(word);
		String result = "";
		for(int i = 0; i < meaning.length(); i++) {
			char ch = meaning.charAt(i);
			if (ch == '\n') {
				result += "<br>";
			} else {
				result += ch;
			}
		}
		return result;
	}
	
	
	public List<DictionariesDTO> getListDictionaries() {
		DictionariesDAO dictDAO = new DictionariesDAO();
		return dictDAO.getDictionaries();
	}
}
